<?php
    session_start();
    if (!($controlpanel = getSession(Config::$session_name)))
    {
        $controlpanel = new ControlPanel(Config::$cpName);
        setSession(Config::$session_name, $controlpanel);
        setSession(Config::$session_name . '_user', $controlpanel::$user);
    } //!($controlpanel = getSession(Config::$session_name))
    else
    {
        $controlpanel        = getSession(Config::$session_name);
        $controlpanel::$user = getSession(Config::$session_name . '_user');
    }
    function getSession($key)
    {
        if (isset($_SESSION[$key]))
            return $_SESSION[$key];
        return null;
    }
    function setSession($key, $val)
    {
        if (isset($_SESSION[$key]))
            return;
        $_SESSION[$key] = $val;
    }
    function delSession($key)
    {
        if (!isset($_SESSION[$key]))
            return;
        unset($_SESSION[$key]);
    }
?>